// pages/mine/mine.js
let app = getApp();
let testAddr = app.globalData.testAddr;
let imgurl = app.globalData.imgurl;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderlist: [{
        id: "1",
        name: "待付款",
      pic: "https://www.goods-asked.cn:6061/img/appimgs/icon_pending_delivery.png"
      },
      {
        id: "2",
        name: "待发货",
        pic: "https://www.goods-asked.cn:6061/img/appimgs/icon_pending_payment.png"
      },
      {
        id: "3",
        name: "待收货",
        pic: "https://www.goods-asked.cn:6061/img/appimgs/icon_pending_received.png"
      },
      {
        id: "4",
        name: "待评价",
        pic: "https://www.goods-asked.cn:6061/img/appimgs/icon_pending_evaluated.png"
      },
      {
        id: "13",
        name: "退款/售后",
        pic: "https://www.goods-asked.cn:6061/img/appimgs/icon_after_sale.png"
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this
    that.getmyselfinfo()
    that.getmembership()
    that.getallorder()
    
  },
  // 获取个人资料
  getmyselfinfo: function() {
    var that = this
    var guestID = wx.getStorageSync("list").guestid
    that.setData({
      guestID: guestID
    })
    app.util.request({
      url: testAddr + "Guest/GetInfoByID?guestID=" + guestID,
      method: "POST",
      data: {},
      success: function(res) {
        var useInfo = res.data
        if (useInfo.imgUrl) {
          useInfo.imgUrl = imgurl + "/guest/" + useInfo.imgUrl
        }
        that.setData({
          useInfo: useInfo
        })
        console.log(res)
      }
    })
  },
  // 跳转查看所有订单
  toallorder: function() {
    var that = this
    var guestID = that.data.guestID
    wx.navigateTo({
      url: '../../../../cardbark/order/order?guestID=' + guestID,
    })
  },
  // 单个跳转查询订单状态列表
  tosinger: function (e) {
    var that = this
    var orderid = e.currentTarget.id
    console.log(orderid)
    var guestID = that.data.guestID
    console.log(guestID)
    var statname = e.currentTarget.dataset.statname
    wx.navigateTo({
      url: '../cardbark/waitpayment/waitpayment?orderid=' + orderid + "&guestID=" + guestID + "&statname=" + statname,
    })
  },
  // 跳转个人资料详情
  infodetail: function(e) {
    var infodetail = e.currentTarget.dataset.infodetail;
    wx.setStorageSync("if_detail", infodetail)
    // console.log()
    wx.navigateTo({
      url: '../../../../cardbark/personaldata/personaldata',
    })
  },
  // 会员详情
  getmembership: function() {
    var that = this
    app.util, wx.request({
      url: testAddr + 'moneyRate/getMoneyType',
      method: 'POST',
      data: '',
      success: function(res) {

        var shiptype = res.data
        that.setData({
          shiptype: shiptype
        })
      },
      fail: function(res) {},
      complete: function(res) {},
    })
  },
  // 获取所有订单
  getallorder: function() {
    var that = this
    app.util.request({
      url: testAddr + "facility_order/getOrderList?guestID=" + 55 + '&pageIndex=' + 1 + '&pageSize=' + 5,
      method: "POST",
      data: {},
      success: function(res) {
        console.log(res)
      }
    })
  },
  //跳转我的合同
  jumpContract:function(){
    wx.navigateTo({
      url: '../../pages/contract/contract',
    })
  },
  jumpBonus:function(){
    wx.navigateTo({
      url: '../../pages/cardbark/bonus/bonus',
    })
  },
  jumpAddress:function(){
    wx.navigateTo({
      url: '../../pages/goodsaddress/goodsaddress',
    })
  },
  jumpCollection:function(){
    wx.navigateTo({
      url: '../../pages/collection/collection',
    })
  },
  jumpTransrecord:function(){
    wx.navigateTo({
      url: '../../pages/transrecord/transrecord',
    })
  },
  jumpMyPoints:function(){
    wx.navigateTo({
      url: '../../pages/mypoints/mypoints',
    })
  },
  jumpShare:function(){
    wx.navigateTo({
      url: '../../pages/cardbark/sharebonus/sharebonus',
    })
  },
  jumpSincerity:function(){
    wx.navigateTo({
      url: '../../pages/detail/sincerity/sincerity',
    })
  },
  jumpCompany(){
    wx.navigateTo({
      url: '../../pages/mycompany/mycompany',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})